
/*!
	\file
	\brief Resultant document.

		\author Igor Mironchik (igor.mironchik at gmail dot com).

        Copyright (c) 2010 - 2011 Igor Mironchik

	Permission is hereby granted, free of charge, to any person
	obtaining a copy of this software and associated documentation
	files (the "Software"), to deal in the Software without
	restriction, including without limitation the rights to use,
	copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the
	Software is furnished to do so, subject to the following
	conditions:

	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
	OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
	HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
	WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
	OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef ESHOPHELPER__DOCUMENT_HPP__INCLUDED
#define ESHOPHELPER__DOCUMENT_HPP__INCLUDED

// Qt include.
#include <QtCore/QMap>
#include <QtCore/QString>

// C++ include.
#include <stdexcept>


namespace eShopHelper {

//
// DocumentException
//

//! Exception in processing document file.
class DocumentException
	:	public std::runtime_error
{
public:
	explicit DocumentException( const QString & what );
	virtual ~DocumentException() throw();

	//! \return Reason of the exception.
	const QString & whatAsQString() const throw();

private:
	//! Reason of the exception.
	QString m_what;
}; // class DocumentException


//
// Document
//

class Document {
public:
	Document();
	~Document();

	//! Correspondencies between Excel files and their format.
	typedef QMap< QString, QString > CorrepondenciesMap;

	//! \return Correspondencies between Excel file and their format.
	const CorrepondenciesMap & correspondencies() const;
	//! \return Correspondencies between Excel file and their format.
	CorrepondenciesMap & correspondencies();

	//! Set correspondencies between Excel file and their format.
	void correspondencies( const CorrepondenciesMap & map );

	//! Add new correspondence.
	void addCorrespondence( const CorrepondenciesMap::key_type & excelFile,
		const CorrepondenciesMap::mapped_type & format );

	//! Del correspondence.
	void delCorrepondence( const CorrepondenciesMap::key_type & excelFile );

	//! Read document from file.
	void readFromFile( const QString & fileName );

	//! Save document into file.
	void saveIntoFile( const QString & fileName ) const;

private:
	//! Correspondencies between Excel files and their format.
	CorrepondenciesMap m_correspondencies;
}; // class Document

} /* namespace eShopHelper */

#endif // ESHOPHELPER__DOCUMENT_HPP__INCLUDED
